% /*******************************************************************************
%  * Main Simulation Routine
%  * *****************************************************************************
%  * @param lower
%  * @param upper
%  * @param m
%  * @param n
%  * @param r
%  * @param k
%  * @param q
%  * @param t
%  * @param z
%  */
function analysis_err(lower,upper,m,n,r,k,is_print,fid)
step_a = 2^(-m);
step_b = 2^(-n);
num = (round((upper-lower)/step_a) + 1)*(round((upper-lower)/step_b) + 1);
%print header
if(is_print)
    fprintf(fid,'a');
    fprintf(fid,',');
    fprintf(fid,'b');
    fprintf(fid,',');
    fprintf(fid,'ans_true');
    fprintf(fid,',');
    fprintf(fid,'ans_true_rnd');
    fprintf(fid,',');
    fprintf(fid,'ans_trunc');        
    fprintf(fid, '\n');       
end
%print rows
index = 0;
for a = lower:step_a:upper
    for b = lower:step_b:upper
        index = index + 1;
        ans_true = a * b;
        ans_trunc = trunc_mult(a,b,0.0,m,n,r,k);                   
        ans_true_r = rnd_near(ans_true, r);        
        if(is_print)            
            disp_bin(a,0,m,fid);
            fprintf(fid, ',');
            disp_bin(b, 0, n, fid);
            fprintf(fid, ',');
            disp_bin(ans_true, 0, m + n, fid);
            fprintf(fid, ',');
            disp_bin(ans_true_r, 0, r, fid);
            fprintf(fid, ',');
            disp_bin(ans_trunc, 0, r, fid);            
            fprintf(fid, '\n');
        end                
    end
end
end